package com.ae.shield;

import com.ae.shield.client.gui.ScreenList;
import com.ae.shield.common.block.BlockList;
import com.ae.shield.common.block.tile.TileEntityList;
import com.ae.shield.common.capability.CapList;
import com.ae.shield.common.config.Config;
import com.ae.shield.common.recipe.ModRecipesType;
import com.ae.shield.common.effect.EffectList;
import com.ae.shield.common.fluid.FluidList;
import com.ae.shield.common.gui.container.ContainerList;
import com.ae.shield.common.items.ItemList;
import com.ae.shield.common.enchantment.shieldSuffix.SuffixList;
import com.ae.shield.common.net.ModNetwork;
import com.ae.shield.common.recipe.conditions.ConditionList;
import com.ae.shield.common.world.gen.feature.OreFeature;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.config.ModConfig;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;

import javax.annotation.Nonnull;

@Mod(ModLib.MOD_ID)
public class AEShieldMod {
    public AEShieldMod() {
        final IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
        ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, Config.config);

        modEventBus.addListener(this::clientSetup);
        modEventBus.addListener(this::setup);

        ItemList.ITEMS.register(modEventBus);
        BlockList.BLOCKS.register(modEventBus);
        FluidList.FLUID.register(modEventBus);
        TileEntityList.TILE_ENTITIES.register(modEventBus);
        ContainerList.CONTAINERS.register(modEventBus);
        SuffixList.SUFFIX.register(modEventBus);
        EffectList.EFFECTS.register(modEventBus);
        ModRecipesType.RECIPE_SERIALIZER.register(modEventBus);
        ModRecipesType.registerType();
        ConditionList.register();
    }

    public void setup(final FMLCommonSetupEvent event){
        CapList.register(event);
        ModNetwork.register();
        OreFeature.setup();

    }

    public void clientSetup(final FMLClientSetupEvent event) {
        ScreenList.registryAll();
    }

//----------------------------------------------创造物品栏----------------------------------------------------------------

    public static final ItemGroup AE_SHIELD = new ModGroup();

    public static class ModGroup extends ItemGroup{
        public ModGroup(){
            super(ModLib.MOD_ID);
        }

        @Nonnull
        @Override
        public ItemStack createIcon() {
            return new ItemStack(ItemList.SHIELD.get());
        }
    }
}
